/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* THIS IS AUTOGENERATED FILE, PLEASE DON`T CHANGE IT MANUALLY */
class ArkResourcesHelper {
    static $r(name, id) {
        let splitted = name.split('.', 2);
        let strType = splitted[1];
        let type = undefined;
        switch (strType) {
            case 'float':
                type = ArkResourcesHelper.FLOAT;
                break;
            case 'color':
            default:
                type = ArkResourcesHelper.COLOR;
                break;
        }
        return { 'id': id !== null && id !== void 0 ? id : -1, 'type': type, 'params': [name], 'bundleName': '', 'moduleName': '' };
    }
}
ArkResourcesHelper.COLOR = 10001;
ArkResourcesHelper.FLOAT = 10002;
class ArkThemeNativeHelper {
    static sendThemeToNative(theme, elmtId) {
        const colorsArray = [
            theme.colors.brand,
            theme.colors.warning,
            theme.colors.alert,
            theme.colors.confirm,
            theme.colors.fontPrimary,
            theme.colors.fontSecondary,
            theme.colors.fontTertiary,
            theme.colors.fontFourth,
            theme.colors.fontEmphasize,
            theme.colors.fontOnPrimary,
            theme.colors.fontOnSecondary,
            theme.colors.fontOnTertiary,
            theme.colors.fontOnFourth,
            theme.colors.iconPrimary,
            theme.colors.iconSecondary,
            theme.colors.iconTertiary,
            theme.colors.iconFourth,
            theme.colors.iconEmphasize,
            theme.colors.iconSubEmphasize,
            theme.colors.iconOnPrimary,
            theme.colors.iconOnSecondary,
            theme.colors.iconOnTertiary,
            theme.colors.iconOnFourth,
            theme.colors.backgroundPrimary,
            theme.colors.backgroundSecondary,
            theme.colors.backgroundTertiary,
            theme.colors.backgroundFourth,
            theme.colors.backgroundEmphasize,
            theme.colors.compForegroundPrimary,
            theme.colors.compBackgroundPrimary,
            theme.colors.compBackgroundPrimaryTran,
            theme.colors.compBackgroundPrimaryContrary,
            theme.colors.compBackgroundGray,
            theme.colors.compBackgroundSecondary,
            theme.colors.compBackgroundTertiary,
            theme.colors.compBackgroundEmphasize,
            theme.colors.compBackgroundNeutral,
            theme.colors.compEmphasizeSecondary,
            theme.colors.compEmphasizeTertiary,
            theme.colors.compDivider,
            theme.colors.compCommonContrary,
            theme.colors.compBackgroundFocus,
            theme.colors.compFocusedPrimary,
            theme.colors.compFocusedSecondary,
            theme.colors.compFocusedTertiary,
            theme.colors.interactiveHover,
            theme.colors.interactivePressed,
            theme.colors.interactiveFocus,
            theme.colors.interactiveActive,
            theme.colors.interactiveSelect,
            theme.colors.interactiveClick,
        ];
        WithTheme.sendThemeToNative(colorsArray, elmtId);
    }
}

if (globalThis.LazyForEach !== undefined) {
    globalThis.LazyForEach.create = function (paramViewId, paramParentView, paramDataSource, paramItemGenerator, paramKeyGenerator, paramUpdateChangedNode) {
        const themeScope = ArkThemeScopeManager.getInstance().lastLocalThemeScope();
        if (themeScope === undefined) {
            if (paramUpdateChangedNode) {
                LazyForEach.createInternal(paramViewId, paramParentView, paramDataSource, paramItemGenerator, paramKeyGenerator, paramUpdateChangedNode);
            }
            else {
                LazyForEach.createInternal(paramViewId, paramParentView, paramDataSource, paramItemGenerator, paramKeyGenerator);
            }
            return;
        }
        const itemGeneratorWrapper = (...params) => {
            const result = ArkThemeScopeManager.getInstance().onDeepRenderScopeEnter(themeScope);
            paramItemGenerator(...params);
            if (result === true) {
                ArkThemeScopeManager.getInstance().onDeepRenderScopeExit();
            }
        };
        if (paramUpdateChangedNode) {
            LazyForEach.createInternal(paramViewId, paramParentView, paramDataSource, itemGeneratorWrapper, paramKeyGenerator, paramUpdateChangedNode);
        }
        else {
            LazyForEach.createInternal(paramViewId, paramParentView, paramDataSource, itemGeneratorWrapper, paramKeyGenerator);
        }
    };
}

if (globalThis.ListItem !== undefined) {
    globalThis.ListItem.create = function (deepRenderFunction, isLazy, options) {
        if (isLazy === false) {
            ListItem.createInternal(deepRenderFunction, isLazy, options);
            return;
        }
        const listItemElmtId = ViewStackProcessor.GetElmtIdToAccountFor();
        const themeScope = ArkThemeScopeManager.getInstance().scopeForElmtId(listItemElmtId);
        if (themeScope === undefined) {
            ListItem.createInternal(deepRenderFunction, isLazy, options);
            return;
        }
        const deepRenderFunctionWrapper = (elmtId, isInitialRender) => {
            const result = ArkThemeScopeManager.getInstance().onDeepRenderScopeEnter(themeScope);
            deepRenderFunction(elmtId, isInitialRender);
            if (result === true) {
                ArkThemeScopeManager.getInstance().onDeepRenderScopeExit();
            }
        };
        ListItem.createInternal(deepRenderFunctionWrapper, isLazy, options);
    };
}

class ArkSystemColors {
    constructor() {
        this.brand = ArkResourcesHelper.$r('sys.color.brand', 125830976);
        this.warning = ArkResourcesHelper.$r('sys.color.warning', 125830979);
        this.alert = ArkResourcesHelper.$r('sys.color.alert', 125830980);
        this.confirm = ArkResourcesHelper.$r('sys.color.confirm', 125830981);
        this.fontPrimary = ArkResourcesHelper.$r('sys.color.font_primary', 125830982);
        this.fontSecondary = ArkResourcesHelper.$r('sys.color.font_secondary', 125830983);
        this.fontTertiary = ArkResourcesHelper.$r('sys.color.font_tertiary', 125830984);
        this.fontFourth = ArkResourcesHelper.$r('sys.color.font_fourth', 125830985);
        this.fontEmphasize = ArkResourcesHelper.$r('sys.color.font_emphasize', 125830986);
        this.fontOnPrimary = ArkResourcesHelper.$r('sys.color.font_on_primary', 125830987);
        this.fontOnSecondary = ArkResourcesHelper.$r('sys.color.font_on_secondary', 125830988);
        this.fontOnTertiary = ArkResourcesHelper.$r('sys.color.font_on_tertiary', 125830989);
        this.fontOnFourth = ArkResourcesHelper.$r('sys.color.font_on_fourth', 125830990);
        this.iconPrimary = ArkResourcesHelper.$r('sys.color.icon_primary', 125830991);
        this.iconSecondary = ArkResourcesHelper.$r('sys.color.icon_secondary', 125830992);
        this.iconTertiary = ArkResourcesHelper.$r('sys.color.icon_tertiary', 125830993);
        this.iconFourth = ArkResourcesHelper.$r('sys.color.icon_fourth', 125830994);
        this.iconEmphasize = ArkResourcesHelper.$r('sys.color.icon_emphasize', 125830995);
        this.iconSubEmphasize = ArkResourcesHelper.$r('sys.color.icon_sub_emphasize', 125830996);
        this.iconOnPrimary = ArkResourcesHelper.$r('sys.color.icon_on_primary', 125831057);
        this.iconOnSecondary = ArkResourcesHelper.$r('sys.color.icon_on_secondary', 125831058);
        this.iconOnTertiary = ArkResourcesHelper.$r('sys.color.icon_on_tertiary', 125831059);
        this.iconOnFourth = ArkResourcesHelper.$r('sys.color.icon_on_fourth', 125831060);
        this.backgroundPrimary = ArkResourcesHelper.$r('sys.color.background_primary', 125831061);
        this.backgroundSecondary = ArkResourcesHelper.$r('sys.color.background_secondary', 125831062);
        this.backgroundTertiary = ArkResourcesHelper.$r('sys.color.background_tertiary', 125831063);
        this.backgroundFourth = ArkResourcesHelper.$r('sys.color.background_fourth', 125831064);
        this.backgroundEmphasize = ArkResourcesHelper.$r('sys.color.background_emphasize', 125831065);
        this.compForegroundPrimary = ArkResourcesHelper.$r('sys.color.comp_foreground_primary', 125831003);
        this.compBackgroundPrimary = ArkResourcesHelper.$r('sys.color.comp_background_primary', 125831004);
        this.compBackgroundPrimaryTran = ArkResourcesHelper.$r('sys.color.comp_background_primary_tran');
        this.compBackgroundPrimaryContrary = ArkResourcesHelper.$r('sys.color.comp_background_primary_contrary', 125831005);
        this.compBackgroundGray = ArkResourcesHelper.$r('sys.color.comp_background_gray', 125831006);
        this.compBackgroundSecondary = ArkResourcesHelper.$r('sys.color.comp_background_secondary', 125831007);
        this.compBackgroundTertiary = ArkResourcesHelper.$r('sys.color.comp_background_tertiary', 125831008);
        this.compBackgroundEmphasize = ArkResourcesHelper.$r('sys.color.comp_background_emphasize', 125831009);
        this.compBackgroundNeutral = ArkResourcesHelper.$r('sys.color.neutral', 125831066);
        this.compEmphasizeSecondary = ArkResourcesHelper.$r('sys.color.comp_emphasize_secondary', 125831011);
        this.compEmphasizeTertiary = ArkResourcesHelper.$r('sys.color.comp_emphasize_tertiary', 125831012);
        this.compDivider = ArkResourcesHelper.$r('sys.color.comp_divider', 125831013);
        this.compCommonContrary = ArkResourcesHelper.$r('sys.color.comp_common_contrary', 125831014);
        this.compBackgroundFocus = ArkResourcesHelper.$r('sys.color.comp_background_focus', 125831015);
        this.compFocusedPrimary = ArkResourcesHelper.$r('sys.color.comp_focused_primary', 125831016);
        this.compFocusedSecondary = ArkResourcesHelper.$r('sys.color.comp_focused_secondary', 125831017);
        this.compFocusedTertiary = ArkResourcesHelper.$r('sys.color.comp_focused_tertiary', 125831018);
        this.interactiveHover = ArkResourcesHelper.$r('sys.color.interactive_hover', 125831019);
        this.interactivePressed = ArkResourcesHelper.$r('sys.color.interactive_pressed', 125831020);
        this.interactiveFocus = ArkResourcesHelper.$r('sys.color.interactive_focus', 125831021);
        this.interactiveActive = ArkResourcesHelper.$r('sys.color.interactive_active', 125831022);
        this.interactiveSelect = ArkResourcesHelper.$r('sys.color.interactive_select', 125831023);
        this.interactiveClick = ArkResourcesHelper.$r('sys.color.interactive_click', 125831024);
    }
}
class ArkSystemCornerRadius {
    constructor() {
        this.none = ArkResourcesHelper.$r('sys.float.corner_radius_none');
        this.level1 = ArkResourcesHelper.$r('sys.float.corner_radius_level1');
        this.level2 = ArkResourcesHelper.$r('sys.float.corner_radius_level2');
        this.level3 = ArkResourcesHelper.$r('sys.float.corner_radius_level3');
        this.level4 = ArkResourcesHelper.$r('sys.float.corner_radius_level4');
        this.level5 = ArkResourcesHelper.$r('sys.float.corner_radius_level5');
        this.level6 = ArkResourcesHelper.$r('sys.float.corner_radius_level6');
        this.level7 = ArkResourcesHelper.$r('sys.float.corner_radius_level7');
        this.level8 = ArkResourcesHelper.$r('sys.float.corner_radius_level8');
        this.level9 = ArkResourcesHelper.$r('sys.float.corner_radius_level9');
        this.level10 = ArkResourcesHelper.$r('sys.float.corner_radius_level10');
        this.level11 = ArkResourcesHelper.$r('sys.float.corner_radius_level11');
        this.level12 = ArkResourcesHelper.$r('sys.float.corner_radius_level12');
        this.level16 = ArkResourcesHelper.$r('sys.float.corner_radius_level16');
    }
}
class ArkSystemPaddings {
    constructor() {
        this.level0 = ArkResourcesHelper.$r('sys.float.padding_level0');
        this.level1 = ArkResourcesHelper.$r('sys.float.padding_level1');
        this.level2 = ArkResourcesHelper.$r('sys.float.padding_level2');
        this.level3 = ArkResourcesHelper.$r('sys.float.padding_level3');
        this.level4 = ArkResourcesHelper.$r('sys.float.padding_level4');
        this.level5 = ArkResourcesHelper.$r('sys.float.padding_level5');
        this.level6 = ArkResourcesHelper.$r('sys.float.padding_level6');
        this.level7 = ArkResourcesHelper.$r('sys.float.padding_level7');
        this.level8 = ArkResourcesHelper.$r('sys.float.padding_level8');
        this.level9 = ArkResourcesHelper.$r('sys.float.padding_level9');
        this.level10 = ArkResourcesHelper.$r('sys.float.padding_level10');
        this.level11 = ArkResourcesHelper.$r('sys.float.padding_level11');
        this.level12 = ArkResourcesHelper.$r('sys.float.padding_level12');
        this.level16 = ArkResourcesHelper.$r('sys.float.padding_level16');
        this.level24 = ArkResourcesHelper.$r('sys.float.padding_level24');
        this.level32 = ArkResourcesHelper.$r('sys.float.padding_level32');
        this.level36 = ArkResourcesHelper.$r('sys.float.padding_level36');
    }
}
class ArkSystemOutlines {
    constructor() {
        this.none = ArkResourcesHelper.$r('sys.float.outline_none');
        this.xs = ArkResourcesHelper.$r('sys.float.outline_extra_small');
        this.s = ArkResourcesHelper.$r('sys.float.outline_small');
        this.m = ArkResourcesHelper.$r('sys.float.outline_medium');
        this.l = ArkResourcesHelper.$r('sys.float.outline_larger');
        this.xl = ArkResourcesHelper.$r('sys.float.outline_extra_larger');
    }
}
class ArkSystemBorders {
    constructor() {
        this.none = ArkResourcesHelper.$r('sys.float.border_none');
        this.xs = ArkResourcesHelper.$r('sys.float.border_extra_small');
        this.s = ArkResourcesHelper.$r('sys.float.border_small');
        this.m = ArkResourcesHelper.$r('sys.float.border_medium');
        this.l = ArkResourcesHelper.$r('sys.float.border_larger');
        this.xl = ArkResourcesHelper.$r('sys.float.border_extra_larger');
    }
}
class ArkSystemShapes {
    constructor() {
        this.cornerRadius = new ArkSystemCornerRadius();
        this.paddings = new ArkSystemPaddings();
        this.borders = new ArkSystemBorders();
        this.outlines = new ArkSystemOutlines();
    }
}
class ArkTypographyWeights {
}
ArkTypographyWeights.thin = 100;
ArkTypographyWeights.ultralight = 200;
ArkTypographyWeights.light = 300;
ArkTypographyWeights.regular = 400;
ArkTypographyWeights.medium = 500;
ArkTypographyWeights.semibold = 600;
ArkTypographyWeights.bold = 700;
ArkTypographyWeights.heavy = 800;
ArkTypographyWeights.black = 900;
class ArkSystemTypography {
    constructor() {
        this.displayLarge = {
            weight: ArkTypographyWeights.light,
            size: ArkResourcesHelper.$r('sys.float.Display_L')
        };
        this.displayMiddle = {
            weight: ArkTypographyWeights.light,
            size: ArkResourcesHelper.$r('sys.float.Display_M')
        };
        this.displaySmall = {
            weight: ArkTypographyWeights.light,
            size: ArkResourcesHelper.$r('sys.float.Display_S')
        };
        this.titleLarge = {
            weight: ArkTypographyWeights.bold,
            size: ArkResourcesHelper.$r('sys.float.Title_L')
        };
        this.titleMiddle = {
            weight: ArkTypographyWeights.bold,
            size: ArkResourcesHelper.$r('sys.float.Title_M')
        };
        this.titleSmall = {
            weight: ArkTypographyWeights.bold,
            size: ArkResourcesHelper.$r('sys.float.Title_S')
        };
        this.subtitleLarge = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Subtitle_L')
        };
        this.subtitleMiddle = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Subtitle_M')
        };
        this.subtitleSmall = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Subtitle_S')
        };
        this.bodyLarge = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Body_L')
        };
        this.bodyMiddle = {
            weight: ArkTypographyWeights.regular,
            size: ArkResourcesHelper.$r('sys.float.Body_M')
        };
        this.bodySmall = {
            weight: ArkTypographyWeights.regular,
            size: ArkResourcesHelper.$r('sys.float.Body_S')
        };
        this.captionLarge = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Caption_L')
        };
        this.captionMiddle = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Caption_M')
        };
        this.captionSmall = {
            weight: ArkTypographyWeights.medium,
            size: ArkResourcesHelper.$r('sys.float.Caption_S')
        };
    }
}
class ArkSystemTheme {
    constructor() {
        this.colors = new ArkSystemColors();
        this.shapes = new ArkSystemShapes();
        this.typography = new ArkSystemTypography();
    }
}
if (globalThis.WithTheme !== undefined) {
    globalThis.WithTheme.create = function (themeOptions) {
        const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
        const theme = ArkThemeScopeManager.getInstance().makeTheme(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.theme);
        const colorMode = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.colorMode;
        if (colorMode && colorMode !== ThemeColorMode.SYSTEM) {
            ArkThemeScopeManager.getInstance().onEnterLocalColorMode(colorMode);
        }
        ArkThemeNativeHelper.sendThemeToNative(theme, elmtId);
        if (colorMode && colorMode !== ThemeColorMode.SYSTEM) {
            ArkThemeScopeManager.getInstance().onExitLocalColorMode();
        }
        if (themeOptions) {
            ArkThemeScopeManager.getInstance().onScopeEnter(elmtId, themeOptions, theme);
        } else {
            ArkThemeScopeManager.getInstance().onScopeEnter(elmtId, {}, theme);
        }
    };
    globalThis.WithTheme.pop = function () {
        ArkThemeScopeManager.getInstance().onScopeExit();
    };
}

class ArkColorsImpl {
    constructor(colors = {}, baselineColors) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
        const customAttribute = this;
        for (let attribute in colors) {
            customAttribute[attribute] = colors[attribute];
        }
        this.brand = (_a = colors === null || colors === void 0 ? void 0 : colors.brand) !== null && _a !== void 0 ? _a : baselineColors.brand;
        const brandColors = ArkColorsImpl.makeBrandColors(colors === null || colors === void 0 ? void 0 : colors.brand);
        this.warning = (_b = colors === null || colors === void 0 ? void 0 : colors.warning) !== null && _b !== void 0 ? _b : baselineColors.warning;
        this.alert = (_c = colors === null || colors === void 0 ? void 0 : colors.alert) !== null && _c !== void 0 ? _c : baselineColors.alert;
        this.confirm = (_d = colors === null || colors === void 0 ? void 0 : colors.confirm) !== null && _d !== void 0 ? _d : baselineColors.confirm;
        this.fontPrimary = (_e = colors === null || colors === void 0 ? void 0 : colors.fontPrimary) !== null && _e !== void 0 ? _e : baselineColors.fontPrimary;
        this.fontSecondary = (_f = colors === null || colors === void 0 ? void 0 : colors.fontSecondary) !== null && _f !== void 0 ? _f : baselineColors.fontSecondary;
        this.fontTertiary = (_g = colors === null || colors === void 0 ? void 0 : colors.fontTertiary) !== null && _g !== void 0 ? _g : baselineColors.fontTertiary;
        this.fontFourth = (_h = colors === null || colors === void 0 ? void 0 : colors.fontFourth) !== null && _h !== void 0 ? _h : baselineColors.fontFourth;
        this.fontEmphasize = (_k = (_j = colors === null || colors === void 0 ? void 0 : colors.fontEmphasize) !== null && _j !== void 0 ? _j : brandColors.primary) !== null && _k !== void 0 ? _k : baselineColors.fontEmphasize;
        this.fontOnPrimary = (_l = colors === null || colors === void 0 ? void 0 : colors.fontOnPrimary) !== null && _l !== void 0 ? _l : baselineColors.fontOnPrimary;
        this.fontOnSecondary = (_m = colors === null || colors === void 0 ? void 0 : colors.fontOnSecondary) !== null && _m !== void 0 ? _m : baselineColors.fontOnSecondary;
        this.fontOnTertiary = (_o = colors === null || colors === void 0 ? void 0 : colors.fontOnTertiary) !== null && _o !== void 0 ? _o : baselineColors.fontOnTertiary;
        this.fontOnFourth = (_p = colors === null || colors === void 0 ? void 0 : colors.fontOnFourth) !== null && _p !== void 0 ? _p : baselineColors.fontOnFourth;
        this.iconPrimary = (_q = colors === null || colors === void 0 ? void 0 : colors.iconPrimary) !== null && _q !== void 0 ? _q : baselineColors.iconPrimary;
        this.iconSecondary = (_r = colors === null || colors === void 0 ? void 0 : colors.iconSecondary) !== null && _r !== void 0 ? _r : baselineColors.iconSecondary;
        this.iconTertiary = (_s = colors === null || colors === void 0 ? void 0 : colors.iconTertiary) !== null && _s !== void 0 ? _s : baselineColors.iconTertiary;
        this.iconFourth = (_t = colors === null || colors === void 0 ? void 0 : colors.iconFourth) !== null && _t !== void 0 ? _t : baselineColors.iconFourth;
        this.iconEmphasize = (_v = (_u = colors === null || colors === void 0 ? void 0 : colors.iconEmphasize) !== null && _u !== void 0 ? _u : brandColors.primary) !== null && _v !== void 0 ? _v : baselineColors.iconEmphasize;
        this.iconSubEmphasize = (_x = (_w = colors === null || colors === void 0 ? void 0 : colors.iconSubEmphasize) !== null && _w !== void 0 ? _w : brandColors.tertiary) !== null && _x !== void 0 ? _x : baselineColors.iconSubEmphasize;
        this.iconOnPrimary = (_y = colors === null || colors === void 0 ? void 0 : colors.iconOnPrimary) !== null && _y !== void 0 ? _y : baselineColors.iconOnPrimary;
        this.iconOnSecondary = (_z = colors === null || colors === void 0 ? void 0 : colors.iconOnSecondary) !== null && _z !== void 0 ? _z : baselineColors.iconOnSecondary;
        this.iconOnTertiary = (_0 = colors === null || colors === void 0 ? void 0 : colors.iconOnTertiary) !== null && _0 !== void 0 ? _0 : baselineColors.iconOnTertiary;
        this.iconOnFourth = (_1 = colors === null || colors === void 0 ? void 0 : colors.iconOnFourth) !== null && _1 !== void 0 ? _1 : baselineColors.iconOnFourth;
        this.backgroundPrimary = (_2 = colors === null || colors === void 0 ? void 0 : colors.backgroundPrimary) !== null && _2 !== void 0 ? _2 : baselineColors.backgroundPrimary;
        this.backgroundSecondary = (_3 = colors === null || colors === void 0 ? void 0 : colors.backgroundSecondary) !== null && _3 !== void 0 ? _3 : baselineColors.backgroundSecondary;
        this.backgroundTertiary = (_4 = colors === null || colors === void 0 ? void 0 : colors.backgroundTertiary) !== null && _4 !== void 0 ? _4 : baselineColors.backgroundTertiary;
        this.backgroundFourth = (_5 = colors === null || colors === void 0 ? void 0 : colors.backgroundFourth) !== null && _5 !== void 0 ? _5 : baselineColors.backgroundFourth;
        this.backgroundEmphasize = (_7 = (_6 = colors === null || colors === void 0 ? void 0 : colors.backgroundEmphasize) !== null && _6 !== void 0 ? _6 : brandColors.primary) !== null && _7 !== void 0 ? _7 : baselineColors.backgroundEmphasize;
        this.compForegroundPrimary = (_8 = colors === null || colors === void 0 ? void 0 : colors.compForegroundPrimary) !== null && _8 !== void 0 ? _8 : baselineColors.compForegroundPrimary;
        this.compBackgroundPrimary = (_9 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundPrimary) !== null && _9 !== void 0 ? _9 : baselineColors.compBackgroundPrimary;
        this.compBackgroundPrimaryTran = (_10 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundPrimaryTran) !== null && _10 !== void 0 ? _10 : baselineColors.compBackgroundPrimaryTran;
        this.compBackgroundPrimaryContrary = (_11 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundPrimaryContrary) !== null && _11 !== void 0 ? _11 : baselineColors.compBackgroundPrimaryContrary;
        this.compBackgroundGray = (_12 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundGray) !== null && _12 !== void 0 ? _12 : baselineColors.compBackgroundGray;
        this.compBackgroundSecondary = (_13 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundSecondary) !== null && _13 !== void 0 ? _13 : baselineColors.compBackgroundSecondary;
        this.compBackgroundTertiary = (_14 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundTertiary) !== null && _14 !== void 0 ? _14 : baselineColors.compBackgroundTertiary;
        this.compBackgroundEmphasize = (_16 = (_15 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundEmphasize) !== null && _15 !== void 0 ? _15 : brandColors.primary) !== null && _16 !== void 0 ? _16 : baselineColors.compBackgroundEmphasize;
        this.compBackgroundNeutral = (_17 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundNeutral) !== null && _17 !== void 0 ? _17 : baselineColors.compBackgroundNeutral;
        this.compEmphasizeSecondary = (_19 = (_18 = colors === null || colors === void 0 ? void 0 : colors.compEmphasizeSecondary) !== null && _18 !== void 0 ? _18 : brandColors.fourth) !== null && _19 !== void 0 ? _19 : baselineColors.compEmphasizeSecondary;
        this.compEmphasizeTertiary = (_21 = (_20 = colors === null || colors === void 0 ? void 0 : colors.compEmphasizeTertiary) !== null && _20 !== void 0 ? _20 : brandColors.fifth) !== null && _21 !== void 0 ? _21 : baselineColors.compEmphasizeTertiary;
        this.compDivider = (_22 = colors === null || colors === void 0 ? void 0 : colors.compDivider) !== null && _22 !== void 0 ? _22 : baselineColors.compDivider;
        this.compCommonContrary = (_23 = colors === null || colors === void 0 ? void 0 : colors.compCommonContrary) !== null && _23 !== void 0 ? _23 : baselineColors.compCommonContrary;
        this.compBackgroundFocus = (_24 = colors === null || colors === void 0 ? void 0 : colors.compBackgroundFocus) !== null && _24 !== void 0 ? _24 : baselineColors.compBackgroundFocus;
        this.compFocusedPrimary = (_25 = colors === null || colors === void 0 ? void 0 : colors.compFocusedPrimary) !== null && _25 !== void 0 ? _25 : baselineColors.compFocusedPrimary;
        this.compFocusedSecondary = (_26 = colors === null || colors === void 0 ? void 0 : colors.compFocusedSecondary) !== null && _26 !== void 0 ? _26 : baselineColors.compFocusedSecondary;
        this.compFocusedTertiary = (_27 = colors === null || colors === void 0 ? void 0 : colors.compFocusedTertiary) !== null && _27 !== void 0 ? _27 : baselineColors.compFocusedTertiary;
        this.interactiveHover = (_28 = colors === null || colors === void 0 ? void 0 : colors.interactiveHover) !== null && _28 !== void 0 ? _28 : baselineColors.interactiveHover;
        this.interactivePressed = (_29 = colors === null || colors === void 0 ? void 0 : colors.interactivePressed) !== null && _29 !== void 0 ? _29 : baselineColors.interactivePressed;
        this.interactiveFocus = (_31 = (_30 = colors === null || colors === void 0 ? void 0 : colors.interactiveFocus) !== null && _30 !== void 0 ? _30 : brandColors.primary) !== null && _31 !== void 0 ? _31 : baselineColors.interactiveFocus;
        this.interactiveActive = (_33 = (_32 = colors === null || colors === void 0 ? void 0 : colors.interactiveActive) !== null && _32 !== void 0 ? _32 : brandColors.primary) !== null && _33 !== void 0 ? _33 : baselineColors.interactiveActive;
        this.interactiveSelect = (_34 = colors === null || colors === void 0 ? void 0 : colors.interactiveSelect) !== null && _34 !== void 0 ? _34 : baselineColors.interactiveSelect;
        this.interactiveClick = (_35 = colors === null || colors === void 0 ? void 0 : colors.interactiveClick) !== null && _35 !== void 0 ? _35 : baselineColors.interactiveClick;
    }
    static makeBrandColors(brandColor) {
        const result = {
            primary: undefined,
            secondary: undefined,
            tertiary: undefined,
            fourth: undefined,
            fifth: undefined,
            sixth: undefined
        };
        if (brandColor) {
            if (brandColor instanceof Object) {
                result.primary = brandColor;
                result.secondary = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.6);
                result.tertiary = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.4);
                result.fourth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.2);
                result.fifth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.1);
                result.sixth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.05);
            }
            else {
                const argbColor = getUINativeModule().resource.getColorValue(brandColor);
                result.primary = argbColor;
                result.secondary = ArkColorsImpl.blendOpacity(argbColor, 0.6);
                result.tertiary = ArkColorsImpl.blendOpacity(argbColor, 0.4);
                result.fourth = ArkColorsImpl.blendOpacity(argbColor, 0.2);
                result.fifth = ArkColorsImpl.blendOpacity(argbColor, 0.1);
                result.sixth = ArkColorsImpl.blendOpacity(argbColor, 0.05);
            }
        }
        return result;
    }
    static makeResourceWithOpacity(resourceColor, opacityRatio) {
        return {
            "id": resourceColor.id,
            "type": resourceColor.type,
            "params": [...resourceColor.params],
            "bundleName": resourceColor.bundleName,
            "moduleName": resourceColor.moduleName,
            "opacityRatio": opacityRatio
        };
    }
    static blendOpacity(argbColor, opacityRatio) {
        if (opacityRatio < 0 || opacityRatio > 1.0) {
            return argbColor;
        }
        const alpha = (argbColor >> 24) & 0xFF;
        const outAlpha = (alpha * opacityRatio) & 0xFF;
        return ((argbColor & 0x00FFFFFF) | (outAlpha & 0xFF) << 24) >>> 0;
    }
}
class ArkCornerRadiusImpl {
    constructor(corners = {}, baselineCorners) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
        this.none = (_a = corners === null || corners === void 0 ? void 0 : corners.none) !== null && _a !== void 0 ? _a : baselineCorners.none;
        this.level1 = (_b = corners === null || corners === void 0 ? void 0 : corners.level1) !== null && _b !== void 0 ? _b : baselineCorners.level1;
        this.level2 = (_c = corners === null || corners === void 0 ? void 0 : corners.level2) !== null && _c !== void 0 ? _c : baselineCorners.level2;
        this.level3 = (_d = corners === null || corners === void 0 ? void 0 : corners.level3) !== null && _d !== void 0 ? _d : baselineCorners.level3;
        this.level4 = (_e = corners === null || corners === void 0 ? void 0 : corners.level4) !== null && _e !== void 0 ? _e : baselineCorners.level4;
        this.level5 = (_f = corners === null || corners === void 0 ? void 0 : corners.level5) !== null && _f !== void 0 ? _f : baselineCorners.level5;
        this.level6 = (_g = corners === null || corners === void 0 ? void 0 : corners.level6) !== null && _g !== void 0 ? _g : baselineCorners.level6;
        this.level7 = (_h = corners === null || corners === void 0 ? void 0 : corners.level7) !== null && _h !== void 0 ? _h : baselineCorners.level7;
        this.level8 = (_j = corners === null || corners === void 0 ? void 0 : corners.level8) !== null && _j !== void 0 ? _j : baselineCorners.level8;
        this.level9 = (_k = corners === null || corners === void 0 ? void 0 : corners.level9) !== null && _k !== void 0 ? _k : baselineCorners.level9;
        this.level10 = (_l = corners === null || corners === void 0 ? void 0 : corners.level10) !== null && _l !== void 0 ? _l : baselineCorners.level10;
        this.level11 = (_m = corners === null || corners === void 0 ? void 0 : corners.level11) !== null && _m !== void 0 ? _m : baselineCorners.level11;
        this.level12 = (_o = corners === null || corners === void 0 ? void 0 : corners.level12) !== null && _o !== void 0 ? _o : baselineCorners.level12;
        this.level16 = (_p = corners === null || corners === void 0 ? void 0 : corners.level16) !== null && _p !== void 0 ? _p : baselineCorners.level16;
    }
}
class ArkPaddingsImpl {
    constructor(paddings = {}, baselinePaddings) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
        this.level0 = (_a = paddings === null || paddings === void 0 ? void 0 : paddings.level0) !== null && _a !== void 0 ? _a : baselinePaddings.level0;
        this.level1 = (_b = paddings === null || paddings === void 0 ? void 0 : paddings.level1) !== null && _b !== void 0 ? _b : baselinePaddings.level1;
        this.level2 = (_c = paddings === null || paddings === void 0 ? void 0 : paddings.level2) !== null && _c !== void 0 ? _c : baselinePaddings.level2;
        this.level3 = (_d = paddings === null || paddings === void 0 ? void 0 : paddings.level3) !== null && _d !== void 0 ? _d : baselinePaddings.level3;
        this.level4 = (_e = paddings === null || paddings === void 0 ? void 0 : paddings.level4) !== null && _e !== void 0 ? _e : baselinePaddings.level4;
        this.level5 = (_f = paddings === null || paddings === void 0 ? void 0 : paddings.level5) !== null && _f !== void 0 ? _f : baselinePaddings.level5;
        this.level6 = (_g = paddings === null || paddings === void 0 ? void 0 : paddings.level6) !== null && _g !== void 0 ? _g : baselinePaddings.level6;
        this.level7 = (_h = paddings === null || paddings === void 0 ? void 0 : paddings.level7) !== null && _h !== void 0 ? _h : baselinePaddings.level7;
        this.level8 = (_j = paddings === null || paddings === void 0 ? void 0 : paddings.level8) !== null && _j !== void 0 ? _j : baselinePaddings.level8;
        this.level9 = (_k = paddings === null || paddings === void 0 ? void 0 : paddings.level9) !== null && _k !== void 0 ? _k : baselinePaddings.level9;
        this.level10 = (_l = paddings === null || paddings === void 0 ? void 0 : paddings.level10) !== null && _l !== void 0 ? _l : baselinePaddings.level10;
        this.level11 = (_m = paddings === null || paddings === void 0 ? void 0 : paddings.level11) !== null && _m !== void 0 ? _m : baselinePaddings.level11;
        this.level12 = (_o = paddings === null || paddings === void 0 ? void 0 : paddings.level12) !== null && _o !== void 0 ? _o : baselinePaddings.level12;
        this.level16 = (_p = paddings === null || paddings === void 0 ? void 0 : paddings.level16) !== null && _p !== void 0 ? _p : baselinePaddings.level16;
        this.level24 = (_q = paddings === null || paddings === void 0 ? void 0 : paddings.level24) !== null && _q !== void 0 ? _q : baselinePaddings.level24;
        this.level32 = (_r = paddings === null || paddings === void 0 ? void 0 : paddings.level32) !== null && _r !== void 0 ? _r : baselinePaddings.level32;
        this.level36 = (_s = paddings === null || paddings === void 0 ? void 0 : paddings.level36) !== null && _s !== void 0 ? _s : baselinePaddings.level36;
    }
}
class ArkOutlinesImpl {
    constructor(outlines = {}, baselineOutlines) {
        var _a, _b, _c, _d, _e, _f;
        this.none = (_a = outlines === null || outlines === void 0 ? void 0 : outlines.none) !== null && _a !== void 0 ? _a : baselineOutlines.none;
        this.xs = (_b = outlines === null || outlines === void 0 ? void 0 : outlines.xs) !== null && _b !== void 0 ? _b : baselineOutlines.xs;
        this.s = (_c = outlines === null || outlines === void 0 ? void 0 : outlines.s) !== null && _c !== void 0 ? _c : baselineOutlines.s;
        this.m = (_d = outlines === null || outlines === void 0 ? void 0 : outlines.m) !== null && _d !== void 0 ? _d : baselineOutlines.m;
        this.l = (_e = outlines === null || outlines === void 0 ? void 0 : outlines.l) !== null && _e !== void 0 ? _e : baselineOutlines.l;
        this.xl = (_f = outlines === null || outlines === void 0 ? void 0 : outlines.xl) !== null && _f !== void 0 ? _f : baselineOutlines.xl;
    }
}
class ArkBordersImpl {
    constructor(borders = {}, baselineBorders) {
        var _a, _b, _c, _d, _e, _f;
        this.none = (_a = borders === null || borders === void 0 ? void 0 : borders.none) !== null && _a !== void 0 ? _a : baselineBorders.none;
        this.xs = (_b = borders === null || borders === void 0 ? void 0 : borders.xs) !== null && _b !== void 0 ? _b : baselineBorders.xs;
        this.s = (_c = borders === null || borders === void 0 ? void 0 : borders.s) !== null && _c !== void 0 ? _c : baselineBorders.s;
        this.m = (_d = borders === null || borders === void 0 ? void 0 : borders.m) !== null && _d !== void 0 ? _d : baselineBorders.m;
        this.l = (_e = borders === null || borders === void 0 ? void 0 : borders.l) !== null && _e !== void 0 ? _e : baselineBorders.l;
        this.xl = (_f = borders === null || borders === void 0 ? void 0 : borders.xl) !== null && _f !== void 0 ? _f : baselineBorders.xl;
    }
}
class ArkShapesImpl {
    constructor(shapes = {}, baselineShapes) {
        this.cornerRadius = new ArkCornerRadiusImpl(shapes === null || shapes === void 0 ? void 0 : shapes.cornerRadius, baselineShapes.cornerRadius);
        this.paddings = new ArkPaddingsImpl(shapes === null || shapes === void 0 ? void 0 : shapes.paddings, baselineShapes.paddings);
        this.borders = new ArkBordersImpl(shapes === null || shapes === void 0 ? void 0 : shapes.borders, baselineShapes.borders);
        this.outlines = new ArkOutlinesImpl(shapes === null || shapes === void 0 ? void 0 : shapes.outlines, baselineShapes.outlines);
    }
}
class ArkTypographyImpl {
    constructor(typography = {}, baselineTypography) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
        this.displayLarge = {
            weight: (_b = (_a = typography === null || typography === void 0 ? void 0 : typography.displayLarge) === null || _a === void 0 ? void 0 : _a.weight) !== null && _b !== void 0 ? _b : ArkTypographyWeights.light,
            size: (_d = (_c = typography === null || typography === void 0 ? void 0 : typography.displayLarge) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : baselineTypography.displayLarge.size
        };
        this.displayMiddle = {
            weight: (_f = (_e = typography === null || typography === void 0 ? void 0 : typography.displayMiddle) === null || _e === void 0 ? void 0 : _e.weight) !== null && _f !== void 0 ? _f : ArkTypographyWeights.light,
            size: (_h = (_g = typography === null || typography === void 0 ? void 0 : typography.displayMiddle) === null || _g === void 0 ? void 0 : _g.size) !== null && _h !== void 0 ? _h : baselineTypography.displayMiddle.size
        };
        this.displaySmall = {
            weight: (_k = (_j = typography === null || typography === void 0 ? void 0 : typography.displaySmall) === null || _j === void 0 ? void 0 : _j.weight) !== null && _k !== void 0 ? _k : ArkTypographyWeights.light,
            size: (_m = (_l = typography === null || typography === void 0 ? void 0 : typography.displaySmall) === null || _l === void 0 ? void 0 : _l.size) !== null && _m !== void 0 ? _m : baselineTypography.displaySmall.size
        };
        this.titleLarge = {
            weight: (_p = (_o = typography === null || typography === void 0 ? void 0 : typography.titleLarge) === null || _o === void 0 ? void 0 : _o.weight) !== null && _p !== void 0 ? _p : ArkTypographyWeights.bold,
            size: (_r = (_q = typography === null || typography === void 0 ? void 0 : typography.titleLarge) === null || _q === void 0 ? void 0 : _q.size) !== null && _r !== void 0 ? _r : baselineTypography.titleLarge.size
        };
        this.titleMiddle = {
            weight: (_t = (_s = typography === null || typography === void 0 ? void 0 : typography.titleMiddle) === null || _s === void 0 ? void 0 : _s.weight) !== null && _t !== void 0 ? _t : ArkTypographyWeights.bold,
            size: (_v = (_u = typography === null || typography === void 0 ? void 0 : typography.titleMiddle) === null || _u === void 0 ? void 0 : _u.size) !== null && _v !== void 0 ? _v : baselineTypography.titleMiddle.size
        };
        this.titleSmall = {
            weight: (_x = (_w = typography === null || typography === void 0 ? void 0 : typography.titleSmall) === null || _w === void 0 ? void 0 : _w.weight) !== null && _x !== void 0 ? _x : ArkTypographyWeights.bold,
            size: (_z = (_y = typography === null || typography === void 0 ? void 0 : typography.titleSmall) === null || _y === void 0 ? void 0 : _y.size) !== null && _z !== void 0 ? _z : baselineTypography.titleSmall.size
        };
        this.subtitleLarge = {
            weight: (_1 = (_0 = typography === null || typography === void 0 ? void 0 : typography.subtitleLarge) === null || _0 === void 0 ? void 0 : _0.weight) !== null && _1 !== void 0 ? _1 : ArkTypographyWeights.medium,
            size: (_3 = (_2 = typography === null || typography === void 0 ? void 0 : typography.subtitleLarge) === null || _2 === void 0 ? void 0 : _2.size) !== null && _3 !== void 0 ? _3 : baselineTypography.subtitleLarge.size
        };
        this.subtitleMiddle = {
            weight: (_5 = (_4 = typography === null || typography === void 0 ? void 0 : typography.subtitleMiddle) === null || _4 === void 0 ? void 0 : _4.weight) !== null && _5 !== void 0 ? _5 : ArkTypographyWeights.medium,
            size: (_7 = (_6 = typography === null || typography === void 0 ? void 0 : typography.subtitleMiddle) === null || _6 === void 0 ? void 0 : _6.size) !== null && _7 !== void 0 ? _7 : baselineTypography.subtitleMiddle.size
        };
        this.subtitleSmall = {
            weight: (_9 = (_8 = typography === null || typography === void 0 ? void 0 : typography.subtitleSmall) === null || _8 === void 0 ? void 0 : _8.weight) !== null && _9 !== void 0 ? _9 : ArkTypographyWeights.medium,
            size: (_11 = (_10 = typography === null || typography === void 0 ? void 0 : typography.subtitleSmall) === null || _10 === void 0 ? void 0 : _10.size) !== null && _11 !== void 0 ? _11 : baselineTypography.subtitleSmall.size
        };
        this.bodyLarge = {
            weight: (_13 = (_12 = typography === null || typography === void 0 ? void 0 : typography.bodyLarge) === null || _12 === void 0 ? void 0 : _12.weight) !== null && _13 !== void 0 ? _13 : ArkTypographyWeights.medium,
            size: (_15 = (_14 = typography === null || typography === void 0 ? void 0 : typography.bodyLarge) === null || _14 === void 0 ? void 0 : _14.size) !== null && _15 !== void 0 ? _15 : baselineTypography.bodyLarge.size
        };
        this.bodyMiddle = {
            weight: (_17 = (_16 = typography === null || typography === void 0 ? void 0 : typography.bodyMiddle) === null || _16 === void 0 ? void 0 : _16.weight) !== null && _17 !== void 0 ? _17 : ArkTypographyWeights.regular,
            size: (_19 = (_18 = typography === null || typography === void 0 ? void 0 : typography.bodyMiddle) === null || _18 === void 0 ? void 0 : _18.size) !== null && _19 !== void 0 ? _19 : baselineTypography.bodyMiddle.size
        };
        this.bodySmall = {
            weight: (_21 = (_20 = typography === null || typography === void 0 ? void 0 : typography.bodySmall) === null || _20 === void 0 ? void 0 : _20.weight) !== null && _21 !== void 0 ? _21 : ArkTypographyWeights.regular,
            size: (_23 = (_22 = typography === null || typography === void 0 ? void 0 : typography.bodySmall) === null || _22 === void 0 ? void 0 : _22.size) !== null && _23 !== void 0 ? _23 : baselineTypography.bodySmall.size
        };
        this.captionLarge = {
            weight: (_25 = (_24 = typography === null || typography === void 0 ? void 0 : typography.captionLarge) === null || _24 === void 0 ? void 0 : _24.weight) !== null && _25 !== void 0 ? _25 : ArkTypographyWeights.medium,
            size: (_27 = (_26 = typography === null || typography === void 0 ? void 0 : typography.captionLarge) === null || _26 === void 0 ? void 0 : _26.size) !== null && _27 !== void 0 ? _27 : baselineTypography.captionLarge.size
        };
        this.captionMiddle = {
            weight: (_29 = (_28 = typography === null || typography === void 0 ? void 0 : typography.captionMiddle) === null || _28 === void 0 ? void 0 : _28.weight) !== null && _29 !== void 0 ? _29 : ArkTypographyWeights.medium,
            size: (_31 = (_30 = typography === null || typography === void 0 ? void 0 : typography.captionMiddle) === null || _30 === void 0 ? void 0 : _30.size) !== null && _31 !== void 0 ? _31 : baselineTypography.captionMiddle.size
        };
        this.captionSmall = {
            weight: (_33 = (_32 = typography === null || typography === void 0 ? void 0 : typography.captionSmall) === null || _32 === void 0 ? void 0 : _32.weight) !== null && _33 !== void 0 ? _33 : ArkTypographyWeights.medium,
            size: (_35 = (_34 = typography === null || typography === void 0 ? void 0 : typography.captionSmall) === null || _34 === void 0 ? void 0 : _34.size) !== null && _35 !== void 0 ? _35 : baselineTypography.captionSmall.size
        };
    }
}
class ArkThemeImpl {
    constructor(baselineTheme, colors, shapes, typography) {
        this.colors = new ArkColorsImpl(colors, baselineTheme.colors);
        this.shapes = new ArkShapesImpl(shapes, baselineTheme.shapes);
        this.typography = new ArkTypographyImpl(typography, baselineTheme.typography);
    }
}
class ArkThemeScopeItem {
    constructor() {
        this.isInWhiteList = undefined;
    }
}
class ArkThemeScopeArray extends Array {
    binarySearch(elmtId) {
        let start = 0;
        let end = this.length - 1;
        while (start <= end) {
            let mid = (start + end) >> 1;
            if (this[mid].elmtId === elmtId) {
                return mid;
            }
            if (elmtId < this[mid].elmtId) {
                end = mid - 1;
            }
            else {
                start = mid + 1;
            }
        }
        return -1;
    }
}
class ArkThemeScope {
    constructor(ownerComponentId, withThemeId, withThemeOptions, theme) {
        this.ownerComponentId = ownerComponentId;
        this.withThemeId = withThemeId;
        this.withThemeOptions = withThemeOptions;
        this.theme = theme;
        this.prevColorMode = this.colorMode();
    }
    getOwnerComponentId() {
        return this.ownerComponentId;
    }
    getWithThemeId() {
        return this.withThemeId;
    }
    addComponentToScope(elmtId, owner, componentName) {
        if (this.isComponentInScope(elmtId)) {
            return;
        }
        if (!this.components) {
            this.components = new ArkThemeScopeArray();
        }
        this.components.push({ elmtId: elmtId, owner: owner, name: componentName });
    }
    removeComponentFromScope(elmtId) {
        if (this.components) {
            const index = this.components.binarySearch(elmtId);
            if (index > -1) {
                this.components.splice(index, 1);
            }
        }
    }
    isComponentInScope(elmtId) {
        return this.components && (this.components.binarySearch(elmtId) > -1);
    }
    componentsInScope() {
        return this.components;
    }
    colorMode() {
        var _a;
        return (_a = this.withThemeOptions.colorMode) !== null && _a !== void 0 ? _a : ThemeColorMode.SYSTEM;
    }
    customTheme() {
        var _a;
        return (_a = this.withThemeOptions.theme) !== null && _a !== void 0 ? _a : {};
    }
    getTheme() {
        return this.theme;
    }
    options() {
        return this.withThemeOptions;
    }
    updateWithThemeOptions(options, theme) {
        this.prevColorMode = this.colorMode();
        this.withThemeOptions = options;
        this.theme = theme;
    }
    isColorModeChanged() {
        return this.prevColorMode !== this.colorMode();
    }
}
class ArkThemeScopeManager {
    constructor() {
        this.localThemeScopes = [];
        this.themeScopes = [];
        this.ifElseLastScope = undefined;
        this.ifElseScopes = [];
        this.listeners = [];
        this.defaultTheme = undefined;
    }
    onComponentCreateEnter(componentName, elmtId, isFirstRender, ownerComponent) {
        this.handledIsFirstRender = isFirstRender;
        this.handledOwnerComponentId = ownerComponent.id__();
        if (this.themeScopes.length === 0 || componentName === 'WithTheme') {
            return;
        }
        const scopesLength = this.localThemeScopes.length;
        let scope = undefined;
        if (isFirstRender) {
            const currentLocalScope = this.localThemeScopes[this.localThemeScopes.length - 1];
            const currentIfElseScope = this.ifElseScopes[this.ifElseScopes.length - 1];
            if (currentLocalScope) {
                scope = currentLocalScope;
                scope.addComponentToScope(elmtId, ownerComponent.id__(), componentName);
            } else if (currentIfElseScope) {
                scope = currentIfElseScope;
                scope.addComponentToScope(elmtId, ownerComponent.id__(), componentName);
            } else {
                const parentScope = ownerComponent.themeScope_;
                if (parentScope) {
                    scope = parentScope;
                    scope.addComponentToScope(elmtId, ownerComponent.id__(), componentName);
                }
            }
        }
        if (scope === undefined) {
            scope = this.scopeForElmtId(elmtId);
        }
        this.handledColorMode = scope === null || scope === void 0 ? void 0 : scope.colorMode();
        if (this.handledColorMode === ThemeColorMode.LIGHT || this.handledColorMode === ThemeColorMode.DARK) {
            this.onEnterLocalColorMode(this.handledColorMode);
        }
        if (componentName === 'If') {
            this.ifElseLastScope = scope;
        }
    }
    onComponentCreateExit(elmtId) {
        if (this.handledColorMode === ThemeColorMode.LIGHT || this.handledColorMode === ThemeColorMode.DARK) {
            this.onExitLocalColorMode();
        }
    }
    onScopeEnter(withThemeId, withThemeOptions, theme) {
        if (this.handledIsFirstRender === true) {
            let themeScope = new ArkThemeScope(this.handledOwnerComponentId, withThemeId, withThemeOptions, theme);
            this.localThemeScopes.push(themeScope);
            this.themeScopes.push(themeScope);
        }
        else {
            const scope = this.themeScopes.find(item => item.getWithThemeId() === withThemeId);
            scope.updateWithThemeOptions(withThemeOptions, theme);
            this.forceRerenderScope(scope);
        }
    }
    onScopeExit() {
        if (this.handledIsFirstRender === true) {
            this.localThemeScopes.pop();
        }
    }
    onViewPUCreate(ownerComponent) {
        this.subscribeListener(ownerComponent);
        ownerComponent.themeScope_ = this.scopeForElmtId(ownerComponent.id__());
    }
    onViewPUDelete(ownerComponent) {
        this.unsubscribeListener(ownerComponent);
        const ownerComponentId = ownerComponent.id__();
        this.themeScopes = this.themeScopes.filter((scope) => {
            if (scope.getOwnerComponentId() === ownerComponentId) {
                const index = this.localThemeScopes.indexOf(scope);
                if (index !== -1) {
                    this.localThemeScopes.splice(index, 1);
                }
                WithTheme.removeThemeInNative(scope.getWithThemeId());
                return false;
            }
            return true;
        });
    }
    onIfElseBranchUpdateEnter() {
        this.ifElseScopes.push(this.ifElseLastScope);
    }
    onIfElseBranchUpdateExit(removedElmtIds) {
        const scope = this.ifElseScopes.pop();
        if (removedElmtIds && scope) {
            removedElmtIds.forEach(elmtId => scope.removeComponentFromScope(elmtId));
        }
    }
    onDeepRenderScopeEnter(themeScope) {
        if (themeScope) {
            this.localThemeScopes.push(themeScope);
            return true;
        }
        return false;
    }
    onDeepRenderScopeExit() {
        this.localThemeScopes.pop();
    }
    subscribeListener(listener) {
        if (this.listeners.includes(listener)) {
            return;
        }
        this.listeners.push(listener);
    }
    unsubscribeListener(listener) {
        const index = this.listeners.indexOf(listener, 0);
        if (index > -1) {
            this.listeners.splice(index, 1);
        }
    }
    themeForElmtId(elmtId) {
        var _a;
        const scope = this.scopeForElmtId(elmtId);
        return (_a = scope === null || scope === void 0 ? void 0 : scope.getTheme()) !== null && _a !== void 0 ? _a : this.defaultTheme;
    }
    getFinalTheme(elmtId) {
        var _a;
        return (_a = this.themeForElmtId(elmtId)) !== null && _a !== void 0 ? _a : ArkThemeScopeManager.SystemTheme;
    }
    scopeForElmtId(elmtId) {
        if (this.handledIsFirstRender) {
            if (this.localThemeScopes.length > 0) {
                return this.localThemeScopes[this.localThemeScopes.length - 1];
            }
        }
        return this.themeScopes.find(item => item.isComponentInScope(elmtId));
    }
    lastLocalThemeScope() {
        if (this.localThemeScopes.length > 0) {
            return this.localThemeScopes[this.localThemeScopes.length - 1];
        }
        return undefined;
    }
    onEnterLocalColorMode(colorMode) {
        getUINativeModule().resource.updateColorMode(colorMode);
    }
    onExitLocalColorMode() {
        getUINativeModule().resource.restore();
    }
    forceRerenderScope(scope) {
        if (scope === undefined) {
            return;
        }
        const components = scope.componentsInScope();
        if (components) {
            components.forEach((item) => {
                this.notifyScopeThemeChanged(item, scope);
            });
        }
    }
    notifyScopeThemeChanged(item, scope) {
        this.listeners.forEach((listener) => {
            var _a, _b;
            const listenerId = listener.id__();
            if (listenerId === item.owner) {
                if (scope.isColorModeChanged()) {
                    listener.forceRerenderNode(item.elmtId);
                }
                else {
                    let isInWhiteList = item.isInWhiteList;
                    if (isInWhiteList === undefined) {
                        isInWhiteList = ArkThemeWhiteList.isInWhiteList(item.name);
                        item.isInWhiteList = isInWhiteList;
                    }
                    if (isInWhiteList === true) {
                        listener.forceRerenderNode(item.elmtId);
                    }
                }
            }
            else if (listenerId === item.elmtId) {
                listener.onWillApplyTheme((_b = (_a = scope === null || scope === void 0 ? void 0 : scope.getTheme()) !== null && _a !== void 0 ? _a : this.defaultTheme) !== null && _b !== void 0 ? _b : ArkThemeScopeManager.SystemTheme);
            }
        });
    }
    makeTheme(customTheme) {
        var _a, _b;
        if (!customTheme) {
            return (_a = this.defaultTheme) !== null && _a !== void 0 ? _a : ArkThemeScopeManager.SystemTheme;
        }
        return new ArkThemeImpl((_b = this.defaultTheme) !== null && _b !== void 0 ? _b : ArkThemeScopeManager.SystemTheme, customTheme.colors, customTheme.shapes, customTheme.typography);
    }
    setDefaultTheme(customTheme) {
        this.defaultTheme = ArkThemeScopeManager.SystemTheme;
        this.defaultTheme = this.makeTheme(customTheme);
        ArkThemeNativeHelper.sendThemeToNative(this.defaultTheme, 0);
        this.notifyGlobalThemeChanged();
    }
    notifyGlobalThemeChanged() {
        this.listeners.forEach(listener => {
            if (listener.parent_ === undefined) {
                listener.onGlobalThemeChanged();
            }
        });
    }
    getWithThemeIdForElmtId(elmtId) {
        var _a, _b;
        return (_b = (_a = this.scopeForElmtId(elmtId)) === null || _a === void 0 ? void 0 : _a.getWithThemeId()) !== null && _b !== void 0 ? _b : 0;
    }
    static getInstance() {
        if (!ArkThemeScopeManager.instance) {
            ArkThemeScopeManager.instance = new ArkThemeScopeManager();
            PUV2ViewBase.setArkThemeScopeManager(ArkThemeScopeManager.instance);
        }
        return ArkThemeScopeManager.instance;
    }
}
ArkThemeScopeManager.SystemTheme = new ArkSystemTheme();
ArkThemeScopeManager.instance = undefined;
globalThis.themeScopeMgr = ArkThemeScopeManager.getInstance();
class ArkThemeWhiteList {
    static isInWhiteList(componentName) {
        let start = 0;
        let end = ArkThemeWhiteList.whiteList.length - 1;
        while (start <= end) {
            let mid = (start + end) >> 1;
            if (ArkThemeWhiteList.whiteList[mid].localeCompare(componentName) === 0) {
                return true;
            }
            if (ArkThemeWhiteList.whiteList[mid].localeCompare(componentName) === 1) {
                end = mid - 1;
            }
            else {
                start = mid + 1;
            }
        }
        return false;
    }
}
ArkThemeWhiteList.whiteList = [
    'AlphabetIndexer',
    'Badge',
    'Button',
    'Checkbox',
    'CheckboxGroup',
    'Counter',
    'DataPanel',
    'DatePicker',
    'Divider',
    'LoadingProgress',
    'Menu',
    'MenuItem',
    'PatternLock',
    'Progress',
    'QRCode',
    'Radio',
    "Scroll",
    'Search',
    'Select',
    'Slider',
    'Swiper',
    'Text',
    'TextClock',
    'TextInput',
    'TextPicker',
    'TimePicker',
    'Toggle',
];
